package com.xunyji.consumer.rest_api;

import com.netflix.discovery.converters.Auto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author 王杨帅
 * @create 2018-08-26 16:06
 * @desc 利用RestTemplate实现远程调用
 **/
@RestController
@RequestMapping(value = "/ribbon")
@Slf4j
public class RestApi_RestTemplate {

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping(value = "/restInfo")
    public String restInfo() {
        String result = restTemplate
                .getForObject("http://provider/test/connect", String.class);
        log.info("获取到的远程信息为：" + result);
        return result;
    }

}

